<template>
  <div class="CategoryListPage">
    <!-- <p v-for="item in propertiesList" :key="item.id">{{ item }}</p> -->
    <div class="titleBox">
      {{ categoryName }}
    </div>
    <ul class="container">
      <li class="item" v-for="item in propertiesList" :key="item.id" @click="aaa(item.id)">
        <div class="img" :style="{ backgroundImage: 'url(' + item.image + ')' }"></div>
        <div class="text box">
          <h3>{{ item.title }}</h3>
          <p>{{ item.desc }}</p>
          <div class="tag">
            <el-tag v-for="item in item.tags" :key="item">{{ item }}</el-tag>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>
<script>
import { getPropertyList } from '@/api/page'
export default {
  data() {
    return {
      // 分类id
      id: '',
      // 房产列表
      propertiesList: [],
      categoryName: '' //分类名
    }
  },
  created() {
    this.getPropertyList()
  },
  methods: {
    // 跳转
    aaa(id) {
      this.$router.push('detail' + '?id=' + id)
    },
    // 获取房产
    async getPropertyList() {
      const res = await getPropertyList(this.$route.query.id)
      // console.log(28, res)
      this.propertiesList = res.data
      console.log(this.propertiesList)
      this.categoryName = this.propertiesList[0].category.title
    }
  }
}
</script>
<style lang="scss" scoped>
.CategoryListPage {
  margin: 0 0;
  padding-bottom: 40px;
  padding-top: 40px;

  // text-align: center;
  position: relative;
  // padding-top: 50px;
  .titleBox {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    // top: 10%;
    border: 1px solid #999;
    display: inline-block;
    width: 253px;
    height: 52px;
    text-align: center;
    line-height: 52px;
    color: rgb(51, 51, 51);
    font-size: 26px;
  }
  .container {
    padding-top: 100px;
    .item {
      margin: 0 auto;
      width: 60%;
      list-style: none;
      display: flex;
      justify-content: space-between;
      border-bottom: 1px solid #ccc;
      padding: 30px 50px;
      cursor: pointer;
      &:last-child {
        border-bottom: none;
      }
      .img {
        display: inline-block;
        width: 300px;
        height: 300px;
        background-size: cover;
      }

      .text {
        display: inline-block;
        width: 500px;
      }
    }
  }
  .el-tag {
    margin-right: 10px;
  }
}
</style>

<style lang="scss" scoped>
// .CategoryListPage {
//   .container {
//     display: flex;
//     flex-wrap: wrap;
//     li{
//       width: 500px;
//         list-style: none;
//         // background-color: #fff;
//         border: 1px solid #000;
//         height: 500px;
//       .img {
//         background-size: cover;
//         background-repeat: no-repeat;
//         height: 400px;
//         width: 500px;
//       }
//       .box{
//         position: relative;
//         font-size: 14px;
//         .tag{
//           top:-50px;
//           position: absolute;
//           background-color:#864f4dc2;
//           width: 100px;
//           height: 100px;
//           margin-left: 5px;
//         }
//       }
//     }
//   }
// }
</style>
